package cn.com.suiyi.shixingshengxian.active;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import cn.com.suiyi.shixingshengxian.R;
import cn.com.suiyi.shixingshengxian.active.adapter.ActiveAdapter;
import cn.com.suiyi.shixingshengxian.base.MVPFragment;
import cn.com.suiyi.shixingshengxian.bean.ActiveBean;

/**
 * Created by Administrator on 2016/7/18.
 */
public class ActiveFragment extends MVPFragment<ActiveContract.ActiveView, ActivePresenter> implements ActiveContract.ActiveView {
    @InjectView(R.id.recycler_active)
    RecyclerView recyclerActive;
private ActiveAdapter adapter;
    private List<ActiveBean.DataBean.ActivityBean> activeBeen;


    @Override
    public ActivePresenter getPresenter() {
        Log.i("tag", "getPresenter: "+1111);
        return new ActivePresenter();
    }

    @Override
    protected void initData() {
        Log.i("tag", "getPresenter: "+2222);


    }

    @Override
    protected void initView() {
        Log.i("tag", "getPresenter: "+3333);
        activeBeen=new ArrayList<>();


    }

    @Override
    public int getLayout() {
        Log.i("tag", "getPresenter: "+4444);
        return R.layout.fragment_active;
    }
    @Override
    public void onSuccess(ActiveBean activeBean) {
        Log.i("tag", "getPresenter: "+5555);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerActive.setLayoutManager(linearLayoutManager);
        activeBeen.addAll(activeBean.getData().getActivity());
        adapter=new ActiveAdapter(activeBeen);
        adapter.notifyDataSetChanged();
        recyclerActive.setAdapter(adapter);
    }

    @Override
    public void onFail(String msg) {

    }
}
